home *** CD-ROM | disk | FTP | other *** search
/ GFX Sensations 1 / Graphic Sensations - Volume 1.iso / com_net / tcp / amitcp / netinclude / sys / time.h < prev    next >
C/C++ Source or Header  |  2000-01-01  |  3KB  |  125 lines

  1. #ifndef SYS_TIME_H
  2. #define SYS_TIME_H
  3. /*
  4.  * $Id: time.h,v 1.14 1993/10/18 05:48:28 jraja Exp $
  5.  *
  6.  * Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  7.  *                    Helsinki University of Technology, Finland.
  8.  *                    All rights reserved.
  9.  *
  10.  */
  11.  
  12. #ifndef DEVICES_TIMER_H
  13. #include <devices/timer.h>
  14. #endif
  15.  
  16. /* 
  17.  * struct timeval is defined in <devices/timer.h>.  It is similar to the
  18.  * struct timeval defined normally in sys/time.h, but the names of the
  19.  * fields are different and the values are unsigned long instead of
  20.  * long. Following code rename the fields so that the UNIX code
  21.  * works correctly. (tv_sec and tv_usec are signed!!)
  22.  */
  23.  
  24. struct compatible_timeval {
  25.   union {
  26.     long s_sec;
  27.     ULONG u_secs;
  28.   } mtv_sec;
  29.   union {
  30.     long s_usec;
  31.     ULONG u_micro;
  32.   } mtv_usec;
  33. };
  34.  
  35. #define timeval compatible_timeval
  36. #define tv_sec mtv_sec.s_sec
  37. #define tv_usec mtv_usec.s_usec
  38. #define tv_secs mtv_sec.u_secs
  39. #define tv_micro mtv_usec.u_micro
  40.  
  41. /*
  42.  * We must define the timerequest, because compatible_timeval is not 
  43.  * compatible with old timeval...
  44.  */
  45. struct compatible_timerequest {
  46.     struct IORequest tr_node;
  47.     struct timeval tr_time;
  48. };
  49. #define timerequest compatible_timerequest
  50.  
  51. #if __SASC
  52. #ifndef PROTO_TIMER_H
  53. #include <proto/timer.h>
  54. #endif
  55. #elif __GNUC__
  56. #ifndef _INLINE_TIMER_H
  57. /*
  58.  * predefine TimerBase to Library to follow SASC convention.
  59.  */
  60. #define BASE_EXT_DECL extern struct Library * TimerBase;
  61. #define BASE_NAME (struct Device *)TimerBase
  62. #include <inline/timer.h>
  63. #endif
  64. #else
  65. #include <clib/timer_protos.h>
  66. #endif
  67.  
  68. #ifdef KERNEL
  69. /*
  70.  * The functionality and interface of get_time() and microtime() is similar
  71.  * to the amiga timer.device's GetSysTime(), so they are just defined as
  72.  * follows:
  73.  */
  74. #define get_time GetSysTime
  75. #define microtime GetSysTime
  76. /* 
  77.  * There are no timezones in V36 timer device, nor tries the KERNEL to 
  78.  * use them.
  79.  */
  80. #define gettimeofday(x,y) GetSysTime(x)    
  81. #else
  82. /*
  83.  * These are not used by AmiTCP/IP itself
  84.  */
  85.  
  86. /*
  87.  * bacause of a name conflict with SAS/C time.h definition 'timezone' and
  88.  * BSD sys/time.h struct timezone, time.h must always be included first.
  89.  * (the struct timezone becomes actually struct __timezone, but this does
  90.  * not raise a problem at the source level).
  91.  */
  92. #if __SASC
  93. #include <time.h>
  94. #endif
  95.  
  96. struct timezone {
  97.     int    tz_minuteswest;    /* minutes west of Greenwich */
  98.     int    tz_dsttime;    /* type of dst correction */
  99. };
  100. #define    DST_NONE    0    /* not on dst */
  101. #define    DST_USA        1    /* USA style dst */
  102. #define    DST_AUST    2    /* Australian style dst */
  103. #define    DST_WET        3    /* Western European dst */
  104. #define    DST_MET        4    /* Middle European dst */
  105. #define    DST_EET        5    /* Eastern European dst */
  106. #define    DST_CAN        6    /* Canada */
  107.  
  108. /* defined in the net.lib */
  109. extern int gettimeofday(struct timeval *tp, struct timezone *tzp);
  110. #endif /* KERNEL */
  111.  
  112. /*
  113.  * Operations on timevals.
  114.  *
  115.  * NB: timercmp does not work for >= or <=.
  116.  */
  117. #define    timerisset(tvp)        ((tvp)->tv_sec || (tvp)->tv_usec)
  118. #define    timercmp(tvp, uvp, cmp)    \
  119.     ((tvp)->tv_sec cmp (uvp)->tv_sec || \
  120.      (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
  121. #define    timerclear(tvp)        (tvp)->tv_sec = (tvp)->tv_usec = 0
  122.  
  123. #endif /* !SYS_TIME_H */
  124.  
  125.